#include "Character.h"

Character::Character(Image& image) {
    Initialize();
    SetImage(image);
}

void Character::Initialize() {
    coord.Setup(0, 0, 32, 48);
    walkSpeed = 3.0f;
    anim.Initialize(4, 4, 0.18f);
    score = 0;
}

/**
 * Character::Move
 * Moves the character based on the direction given
 */
void Character::Move(Direction dir) {
    if (dir == UP) {
        anim.ChangeAnim(UP);
        coord.y -= walkSpeed;
    } else if (dir == DOWN) {
        anim.ChangeAnim(DOWN);
        coord.y += walkSpeed;
    } else if (dir == LEFT) {
        anim.ChangeAnim(LEFT);
        coord.x -= walkSpeed;
    } else if (dir == RIGHT) {
        anim.ChangeAnim(RIGHT);
        coord.x += walkSpeed;
    }
    anim.Animate(sprite);
}

string Character::GetScoreString() {
    stringstream txtScore;
    txtScore << "Score: " << score;

    return txtScore.str();
}

string Character::GetRank() {
    string rank;
    if (score < 10) {
        rank = "Newbie";
    } else if (score < 20) {
        rank = "Twig Sharpener";
    } else if (score < 30) {
        rank = "Toothpick Whittler";
    } else if (score < 40) {
        rank = "Popsickle Stick Apprentice";
    } else if (score < 50) {
        rank = "Bonsai Samurai";
    } else if (score < 75) {
        rank = "Stump Sorter";
    } else if (score < 100) {
        rank = "Plank Patron";
    } else if (score < 125) {
        rank = "Tree Wannabe";
    } else if (score < 150) {
        rank = "Elder Oak";
    } else {
        rank = "Yggdrasil";
    }
    return rank;
}

